﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <link rel="stylesheet" href="Console/styles/main-styles.css" />
    <link href="Console/styles/js-console.css" rel="stylesheet" />
</head>
<body>
    <h3>Write a function for extracting all email addresses from given text. All substrings that match the format should be recognized as emails. Return the emails as array of strings.</h3>

    <label for="tb-first">Input a Url: </label>
    <input type="text" id="tb-first" />
    <div id="wrapper">
        <br />
        <a href="#" onclick="runProgram()">Run program!</a>
        <div id="console">
        </div>
    </div>
    <script src="Console/scripts/js-console.js">	  
	</script>
    <script>

        // Gets the user input
        function getInput() {
            var mail = document.getElementById('tb-first').value;
            return mail;
        }

        // Extract e-mails
        function extractMails(mail) {
            mail = mail + "";
            var outArray = mail.match(/\w+@\w+\.\w+/gi);

            return outArray;
        }

        //run program
        function runProgram() {
            var mail = getInput();
            jsConsole.writeLine(extractMails(mail));
        }
	</script>
</body>
</html>
